///单例
class Singleton {
  ///私有的命名构造函数
  Singleton._internal();

  ///声明一个单例
  static final Singleton instance = Singleton._internal();

  ///工厂构造函数返回单例
  factory Singleton() => instance;
}

///非单例
class NotSingleton {}

main() {
  ///创建多个实例，但单例只会有一个
  Singleton singletonOne = Singleton();
  Singleton singletonTwo = Singleton();
  print(singletonOne == singletonTwo); //ture
  NotSingleton notSingletonOne = NotSingleton();
  NotSingleton notSingletonTwo = NotSingleton();
  print(notSingletonOne == notSingletonTwo); //false

}
